package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SnowFlakeUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.SalesInventoryMapper;
import com.ruoyi.system.domain.SalesInventory;
import com.ruoyi.system.service.ISalesInventoryService;

/**
 * 销售库存Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-10-18
 */
@Service
@Transactional
public class SalesInventoryServiceImpl implements ISalesInventoryService 
{
    @Autowired
    private SalesInventoryMapper salesInventoryMapper;

    /**
     * 查询销售库存
     * 
     * @param id 销售库存主键
     * @return 销售库存
     */
    @Override
    public SalesInventory selectSalesInventoryById(Long id)
    {
        return salesInventoryMapper.selectSalesInventoryById(id);
    }

    /**
     * 查询销售库存列表
     * 
     * @param salesInventory 销售库存
     * @return 销售库存
     */
    @Override
    public List<SalesInventory> selectSalesInventoryList(SalesInventory salesInventory)
    {
        return salesInventoryMapper.selectSalesInventoryList(salesInventory);
    }

    /**
     * 新增销售库存
     * 
     * @param salesInventory 销售库存
     * @return 结果
     */
    @Override
    public int insertSalesInventory(SalesInventory salesInventory)
    {
        if(salesInventory.getId()==null){
        salesInventory.setId(SnowFlakeUtils.snowFlakeId());
    }
        salesInventory.setCreateTime(DateUtils.getNowDate());
        return salesInventoryMapper.insertSalesInventory(salesInventory);
    }

    /**
     * 修改销售库存
     * 
     * @param salesInventory 销售库存
     * @return 结果
     */
    @Override
    public int updateSalesInventory(SalesInventory salesInventory)
    {
        return salesInventoryMapper.updateSalesInventory(salesInventory);
    }

    /**
     * 批量删除销售库存
     * 
     * @param ids 需要删除的销售库存主键
     * @return 结果
     */
    @Override
    public int deleteSalesInventoryByIds(Long[] ids)
    {
        return salesInventoryMapper.deleteSalesInventoryByIds(ids);
    }

    /**
     * 删除销售库存信息
     * 
     * @param id 销售库存主键
     * @return 结果
     */
    @Override
    public int deleteSalesInventoryById(Long id)
    {
        return salesInventoryMapper.deleteSalesInventoryById(id);
    }

    /**
     * 批量---逻辑删除
     *
     * @param ids 需要删除的销售库存ID
     * @return 结果
     */
    @Override
    public int setDeleteByIds(Long[] ids)
    {
        Long userId = SecurityUtils.getUserId();
        String userNickName = SecurityUtils.getUserNickName();
        return salesInventoryMapper.setDeleteByIds(ids,userId,userNickName);
    }

    /**
     * 删除---逻辑删除
     *
     * @param id 销售库存ID
     * @return 结果
     */
    @Override
    public int setDeleteById(Long id)
    {
        Long userId = SecurityUtils.getUserId();
        String userNickName = SecurityUtils.getUserNickName();
        return salesInventoryMapper.setDeleteById(id,userId,userNickName);
    }

}
